| @@ -4,6 +4,7 @@ describe Agents::SchedulerAgent do | ||
| 4 | 4 | before do | 
| 5 | 5 |      @agent = Agents::SchedulerAgent.new(name: 'Example', options: { 'schedule' => '0 * * * *' }) | 
| 6 | 6 | @agent.user = users(:bob) | 
| 7 | + @agent.save | |
| 7 | 8 | end | 
| 8 | 9 |  | 
| 9 | 10 | describe "validation" do | 
| @@ -36,6 +37,22 @@ describe Agents::SchedulerAgent do | ||
| 36 | 37 | end | 
| 37 | 38 | end | 
| 38 | 39 |  | 
| 40 | + describe "save" do | |
| 41 | + it "should delete memory['scheduled_at'] if and only if options is changed" do | |
| 42 | + time = Time.now.to_i | |
| 43 | + | |
| 44 | + @agent.memory['scheduled_at'] = time | |
| 45 | + @agent.save | |
| 46 | + @agent.memory['scheduled_at'].should == time | |
| 47 | + | |
| 48 | + @agent.memory['scheduled_at'] = time | |
| 49 | + # Currently @agent.options[]= is not detected | |
| 50 | +      @agent.options = { 'schedule' => '*/5 * * * *' } | |
| 51 | + @agent.save | |
| 52 | + @agent.memory['scheduled_at'].should be_nil | |
| 53 | + end | |
| 54 | + end | |
| 55 | + | |
| 39 | 56 | describe "check!" do | 
| 40 | 57 | it "should run targets" do | 
| 41 | 58 | targets = [agents(:bob_website_agent), agents(:bob_weather_agent)] |